let crypto;
try {
  crypto = require('crypto');
} catch (err) {
  console.log('不支持 crypto');
}

const password = 'abc123'

const hash = crypto
  // .createHash('sha1')
  .createHash('md5')
  // .update(password, 'utf-8')
  .update(password)
  .digest('hex') // 16进制

console.log(hash)

const hash2 = crypto.createHmac('sha256', password)
                .update('I love you')
                .digest('hex')
console.log(hash2)